package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@TableName("t_seller_info")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.SellerInfoMapper")
public class SellerInfoDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 机构主键id
     */
    @TableField(value = "org_id")
    private Long orgId;

    /**
     * 企业名称
     */
    @TableField(value = "seller_name")
    private String sellerName;

    /**
     * 税号
     */
    @TableField(value = "seller_credit_code")
    private String sellerCreditCode;

    /**
     * 开户银行账号
     */
    @TableField(value = "seller_bank_code")
    private String sellerBankCode;

    /**
     * 开户行名称
     */
    @TableField(value = "seller_open_bank")
    private String sellerOpenBank;

    /**
     * 企业地址
     */
    @TableField(value = "seller_address")
    private String sellerAddress;

    /**
     * 注册电话
     */
    @TableField(value = "seller_phone")
    private String sellerPhone;

    /**
     * 开票员
     */
    @TableField(value = "handler")
    private String handler;

    /**
     * 收款人
     */
    @TableField(value = "payee")
    private String payee;

    /**
     * 复核人
     */
    @TableField(value = "checker")
    private String checker;

    /**
     * 税率
     */
    @TableField(value = "rate")
    private Integer rate;

    /**
     * 发票备注信息
     */
    @TableField(value = "invoice_remark")
    private String invoiceRemark;

    @TableField(value = "token")
    private String token;

    @TableField(value = "refresh_token")
    private String refreshToken;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    public SellerInfoVo buildVo() {
        return new SellerInfoVo(id, orgId, sellerName, sellerCreditCode, sellerBankCode, sellerOpenBank, sellerAddress, sellerPhone, handler, payee, checker, rate, invoiceRemark, token, refreshToken, gmtCreate, gmtModified, userCreate, userModified);
    }

    public static SellerInfoDO of(SellerInfoVo vo) {
        return new SellerInfoDO(vo.getId(), vo.getOrgId(), vo.getSellerName(), vo.getSellerCreditCode(), vo.getSellerBankCode(), vo.getSellerOpenBank(), vo.getSellerAddress(), vo.getSellerPhone(), vo.getHandler(), vo.getPayee(), vo.getChecker(), vo.getRate(), vo.getInvoiceRemark(), vo.getToken(), vo.getRefreshToken(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified());
    }
}
